 <!--
* description: 维修反结算查询
* author: chenjingwen
* createdDate: 2021-2-24
-->
<template>
  <div class="app-container app-container-table">
    <one-table-template
      ref="multipleTable"
      :dynamic-buttons="tableButtons"
      :dynamic-components="tableComponents"
      :dynamic-table-cols="tableCols"
      :dynamic-api-config="apiConfig"
      :dynamic-form-fields="formField"
      :dynamic-is-show-select="true"
      :dynamic-is-show-more-btn="true"
    />

     <edit
      v-if="editPopupsVisible"
      :key="editPopupsKey"
      :popups-visible="editPopupsVisible"
      :data-for-form="editRowData"
      :popups-state="editPopupsState"
      :title-name="titleName"
      @close="close"
      @save="save"
    /> 
  </div>
</template>
<script>
import { oneTableWithViewTemplateMixins } from "@/components/mixins/oneTableWithViewTemplateMixins";
import OneTableTemplate from "@/components/templates/oneTable";
import { managements } from "@/api/se/bookingManagement";
import { exportExcel } from "@/utils/getTimeString.js";
import Vue from "vue";
import edit from "./edit";


export default {
  name: "maintenancecounterSettlement",

  components: {
    OneTableTemplate,
    // Edit: () => import("./edit"),
    edit
  },

  // 组件混入对象：{data[listQuery] methods[queryTable]}
  mixins: [oneTableWithViewTemplateMixins],

  // 阻塞路由预加载网格中组件的数据
  beforeRouteEnter(to, from, next) {
    Vue.prototype.$ConfigCache.CacheConfig.initData([to.path, ""], function () {
      next();
    });
  },
   
  data() {
    // 页面标识（与上面beforeRouteEnter中的对应）
    const viewPageCode = this.$route.path;

    // 绑定事件配置化事件
    this.$ConfigCache.CacheConfig.bindEvent(this, [viewPageCode]);

    return {
      // 网格查询API配置对象
      apiConfig: managements.queryiCounter,
      editRowData: {},
      selectData: {},
      editPopupsVisible: false,

      // 动态组件-按钮
      tableButtons: [
        {
          compKey: "btnKey3",
          type: "primary",
          size: "small",
          name: "search",
          clickEvent: () => this.queryTable(1),
          text: this.$t("sys.button.query"), // 查询
          position: "right",
          fuzzySearch: true,
        },
        {
          compKey: "btnKey1",
          size: "small",
          name: "export",
          clickEvent: () => this.exportExcel111(), //导出
          text: "导出",
          position: "right", //
        },

        {
          compKey: "btnKey4",
          type: "",
          size: "small",
          name: "reset",
          clickEvent: () => this.reset(),
          text: this.$t("sys.button.reset"),
          position: "right", // 重置
        },
      ],
      // 动态组件-查询条件
      tableComponents:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
          .tableComponents.length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path]
              .tableComponents
          : [
             
               {
                compKey: "compKey5",
                labelName: "日期类型: ",
                codeField: "partRepairType",
                component: () => import("@/components/org/LookupValue"),
                oFields: "statusId,statusText",
                options: [
                  { statusId: "1", statusText: "反结算日期" },
                  { statusId: "0", statusText: "收款日期" },
                ],
                type: "dropdownList",
                isMul: false,
                isMust: true,
              },


              {
                compKey: "key8",
                labelName: "起止日期:",
                codeField: "appointDate",
                component: () =>
                  import("@/components/org/datePicker/twoDatePicker.vue"),
                type: "twoDatePicker",

                isMul: false,
                isMust: true,
              },

              {
                compKey: "compKey3",
                labelName: "派工单号：",
                codeField: "repairOrderCode",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMul: false,
                isMust: true,
              },
              {
                compKey: "compKey3",
                labelName: "车牌号：",
                codeField: "carLicense",
              component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMul: false,
                isMust: true,
              },
              {
                compKey: "key8",
                labelName: "VIN码:",
                codeField: "vin",
                lookuptype: "VE0185",
                component: () => import("@/components/org/LookupValue"),
                type: "dropdownList",
                isMul: false,
                isMust: false,
              },
              {
                compKey: "compKey3",
                labelName: "送修人：",
                codeField: "repairMan",
                component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMul: false,
                isMust: false,
              },
              {
                compKey: "key8",
                labelName: "送修人电话：",
                codeField: "repairTel",
               component: () => import("@/components/org/commonInput"),
                type: "inputText",
                isMul: false,
                isMust: false,
              },
              {
                compKey: "key8",
                labelName: "服务顾问：",
                codeField: "saEmpId",
                lookuptype: "VE0185",
                component: () => import("@/components/org/LookupValue"),
                type: "dropdownList",
                isMul: false,
                isMust: false,
              },
            ],
      // 动态生成网格列
      tableCols:
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path] &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols &&
        this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          .length > 0
          ? this.$ConfigCache.CacheConfig.cacheData[this.$route.path].tableCols
          : [
              {
                prop: "subsidyId",
                label: "主键ID",
                hidden: true,
                alwaysHidden: true,
              },
              {
                prop: "updateControlId",
                label: "并发控制ID",
                hidden: true,
                alwaysHidden: true,
              },
              {
                prop: "controlBtn",
                label: "操作",
                width: 100,
                fixed: true,
                isComponent: true,
                comps: [
                  {
                    compKey: "propKey1",
                    labelName: "反结算",
                    component: () => import("@/components/org/linkButton"),
                    clickEvent: (index) => this.edit(index),
                  },
                ],
              },

              {
                prop: "REPAIR_ORDER_CODE",
                label: "派工单号",
              },
              {
                prop: "CAR_LICENSE",
                label: "车牌号",
              },
              {
                prop: "REPAIR_TIME",
                label: "到店时间",
              },

              {
                prop: "REPAIR_MAN",
                label: "送修人",
              },
              {
                prop: "REPAIR_TEL",
                label: "送修人电话",
              },
              {
                prop: "VIN",
                label: "VIN码",
              },
              {
                prop: "AUDIT_BALANCE_DATE",
                label: "收款时间",
              },
              {
                prop: "REPAIR_BALANCE_CODE",
                label: "结算单号",
              },
              {
                prop: "WI_AMOUNT",
                label: "应收工时费",
              },
              {
                prop: "PART_AMOUNT",
                label: "应收备件费",
              },

              {
                prop: "OTHER_AMOUNT",
                label: "应收其他费",
              },
              {
                prop: "FACT_AMOUNT",
                label: "实收费用",
              },
              {
                prop: "BALANCE_EMP_ID",
                label: "反结算责任人",
              },
              {
                prop: "SUBMIT_BALANCE_DATE",
                label: "反结算时间",
              },
              {
                prop: "CANCEL_BALANCE_REASON",
                label: "反结算原因",
              },
            ],

      // 表单数据
      formField: this.$utils.getFormField(
        this,
        {
          partRepairType:'',//日期类型
           appointDate:'',//起止日期
            repairOrderCode:'',//派工单号：
             carLicense:'',//车牌号：
              vin:'',//vin
               repairMan:'',//送修人：
                repairTel:'',//送修人电话：
                 saEmpId:'',//服务顾问：
         
        },
        this.$ConfigCache.CacheConfig.cacheData[viewPageCode]
      ),
    };
  },

  mounted() {
    // 列表查询
    this.queryTable(1);

    this.$refs.multipleTable.list = [
      {
        index: 1,
      },
    ];
  },

  methods: {
     exportExcel111() {
      //导出
      // outsourcingsupplierqueryexportexcel

      exportExcel(
        this.formField,
        managements.queryIntmentExport.APIUrl,
        managements.queryIntmentExport.ServiceCode,
        "维修反查询导出"
      );
    },
    edit(index) {
      // this.editPopupsState = "edit";
      this.editPopupsVisible = true;
      // this.editRowData = this.$refs["multipleTable"].list[index];
    },
    close() {
      this.editPopupsVisible = false;
      this.queryTable(1);
    },
  },
};
</script>
